/**
 * 日期格式化
 * @param format
 * @returns
 */
Date.prototype.Format = function(format){ 
	var o = { 
	"M+" : this.getMonth()+1, //month 
	"d+" : this.getDate(), //day 
	"h+" : this.getHours(), //hour 
	"m+" : this.getMinutes(), //minute 
	"s+" : this.getSeconds(), //second 
	"q+" : Math.floor((this.getMonth()+3)/3), //quarter 
	"S" : this.getMilliseconds() //millisecond 
	} 

	if(/(y+)/.test(format)) { 
	format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
	} 

	for(var k in o) { 
	if(new RegExp("("+ k +")").test(format)) { 
	format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); 
	} 
	} 
	return format; 
	} 
function createProHtml(p,i){
	
	 var html='';
     var hangClass='ul-header bg-white';
     if(i%2!=0){
       hangClass='ul-header bg-second';
     }
     var code =p.CODE;
     if(code==""||code ==null){
     	code="-";
     }
   //管线名称
		var LINENAME="";
		if(null==p.LINENAME||""==p.LINENAME){
			LINENAME="-";
		}else{
			LINENAME=p.LINENAME;
		}
		
		//管段名称
		var SEGMENTNAME="-";
		if(null!=p.SEGMENTNAME&&""!=p.SEGMENTNAME){
			SEGMENTNAME=p.SEGMENTNAME;
		}
	
		//钢管编号
		var PIPE_NUMBER="-";
		if(null!=p.PIPE_NUMBER&&""!=p.PIPE_NUMBER){
			PIPE_NUMBER=p.PIPE_NUMBER;
		}
		
		//出厂编号
		var MANUFACTURED_NUM="-";
		if(null!=p.MANUFACTURED_NUM&&""!=p.MANUFACTURED_NUM){
			MANUFACTURED_NUM=p.MANUFACTURED_NUM;
		}
		
		//管材
		var MATERIAL="-";
		if(null!=p.MATERIAL&&""!=p.MATERIAL){
			MATERIAL=p.MATERIAL;
		}
		
		//钢管类型
		var PIPE_TYPE="-";
		if(null!=p.PIPE_TYPE&&""!=p.PIPE_TYPE){
			PIPE_TYPE=p.PIPE_TYPE;
		}
		
		//制管焊缝类型
		var MANUPIPESEAM_TYPE="-";
		if(null!=p.MANUPIPESEAM_TYPE&&""!=p.MANUPIPESEAM_TYPE){
			MANUPIPESEAM_TYPE=p.MANUPIPESEAM_TYPE;
		}
		
		//上游环焊缝编号
		var UGWW_NUMBER="-";
		if(null!=p.UGWW_NUMBER&&""!=p.UGWW_NUMBER){
			UGWW_NUMBER=p.UGWW_NUMBER;
		}
		
		//下游环焊缝编号
		var DGWW_NUMBER="-";
		if(null!=p.DGWW_NUMBER&&""!=p.DGWW_NUMBER){
			DGWW_NUMBER=p.DGWW_NUMBER;
		}
		
		//炉批号
		var STOVESERIAL_NUM="-";
		if(null!=p.STOVESERIAL_NUM&&""!=p.STOVESERIAL_NUM){
			STOVESERIAL_NUM=p.STOVESERIAL_NUM;
		}
		
		//管径
		var DIAMETER="-";
		if(null!=p.DIAMETER&&""!=p.DIAMETER){
			DIAMETER=p.DIAMETER;
		}
		
		//壁厚
		var WALL_THICKNESS="-";
		if(null!=p.WALL_THICKNESS&&""!=p.WALL_THICKNESS){
			WALL_THICKNESS=p.WALL_THICKNESS;
		}
		
		//管节长度
		var PIPE_LENGTH="-";
		if(null!=p.PIPE_LENGTH&&""!=p.PIPE_LENGTH){
			PIPE_LENGTH=p.PIPE_LENGTH;
		}
		
		//防腐层材料
		var COATING_MATERIAL="-";
		if(null!=p.COATING_MATERIAL&&""!=p.COATING_MATERIAL){
			COATING_MATERIAL=p.COATING_MATERIAL;
		}
		
		//防腐层安装地点
		var COATING_SOURCE="-";
		if(null!=p.COATING_SOURCE&&""!=p.COATING_SOURCE){
			COATING_SOURCE=p.COATING_SOURCE;
		}
		
		//内外防腐
		var INTER_NALOREXTERNAL="-";
		if(null!=p.INTER_NALOREXTERNAL&&""!=p.INTER_NALOREXTERNAL){
			INTER_NALOREXTERNAL=p.INTER_NALOREXTERNAL;
		}
		
		//防腐层厚度
		var COATING_THICKNESS="-";
		if(null!=p.COATING_THICKNESS&&""!=p.COATING_THICKNESS){
			COATING_THICKNESS=p.COATING_THICKNESS;
		}
		
		//检漏电压
		var TEST_VOLTAGE="-";
		if(null!=p.TEST_VOLTAGE&&""!=p.TEST_VOLTAGE){
			TEST_VOLTAGE=p.TEST_VOLTAGE;
		}
		
		//钢管生产厂家
		var PIPE_MANUFACTURER="-";
		if(null!=p.PIPE_MANUFACTURER&&""!=p.PIPE_MANUFACTURER){
			PIPE_MANUFACTURER=p.PIPE_MANUFACTURER;
		}
		
		//钢管生产日期
		var PIPE_MANUFACTURE_DATE="-";
		if(null!=p.PIPE_MANUFACTURE_DATE&&""!=p.PIPE_MANUFACTURE_DATE){
			PIPE_MANUFACTURE_DATE=new Date(p.PIPE_MANUFACTURE_DATE).Format("yyyy-MM-dd");
		}
		
		
		//防腐层制造厂商
		var COATING_MANUFACTURER="-";
		if(null!=p.COATING_MANUFACTURER&&""!=p.COATING_MANUFACTURER){
			COATING_MANUFACTURER=p.COATING_MANUFACTURER;
		}
		
		//防腐层制造日期
		var COATING_MANUFACTURE_DATE="-";
		if(null!=p.COATING_MANUFACTURE_DATE&&""!=p.COATING_MANUFACTURE_DATE){
			COATING_MANUFACTURE_DATE=new Date(p.COATING_MANUFACTURE_DATE).Format("yyyy-MM-dd");
		}
		
		//记录人
		var RECORDER="-";
		if(null!=p.RECORDER&&""!=p.RECORDER){
			RECORDER=p.RECORDER;
		}
		
		//记录时间
		var RECORDTIME="-";
		if(null!=p.RECORDTIME&&""!=p.RECORDTIME){
			RECORDTIME=new Date(p.RECORDTIME).Format("yyyy-MM-dd");
		}
		
		//备注
		var CREATE_REMARK="-";
		if(null!=p.CREATE_REMARK&&""!=p.CREATE_REMARK){
			CREATE_REMARK=p.CREATE_REMARK;
		}

		//详情数据
		var hhtml='<div class=\"show-ul none\">'
			+' <ul class=\"show-list\">'
			+'<li> <span class=\"s1\">统一编号:</span><span class=\"s2\">'+code+'</span></li>'
			+'<li> <span class=\"s1\">管道名称:</span><span class=\"s2\">'+LINENAME+'</span></li>'
			+'<li> <span class=\"s1\">管段名称:</span> <span class=\"s2\">'+SEGMENTNAME+'</span></li>'
			+'<li> <span class=\"s1\">钢管编号:</span> <span class=\"s2\">'+PIPE_NUMBER+'</span></li>'
			+'<li> <span class=\"s1\">出厂编号:</span> <span class=\"s2\">'+MANUFACTURED_NUM+'</span></li>'
			+'<li> <span class=\"s1\">管材:</span> <span class=\"s2\">'+MATERIAL+'</span></li>'
			+'<li> <span class=\"s1\">钢管类型:</span> <span class=\"s2\"></span>'+PIPE_TYPE+'</li>'
			+'<li> <span class=\"s1\">制管焊缝类型:</span> <span class=\"s2\">'+MANUPIPESEAM_TYPE+'</span></li>'
			+'<li> <span class=\"s1\">上游环焊缝焊接编号:</span> <span class=\"s2\">'+UGWW_NUMBER+'</span></li>'
			+'<li> <span class=\"s1\">下游环焊缝焊接编号:</span> <span class=\"s2\">'+DGWW_NUMBER+'</span></li>'
			+'<li> <span class=\"s1\">炉批号:</span> <span class=\"s2\">'+STOVESERIAL_NUM+'</span></li>'
			+'<li> <span class=\"s1\">管径(mm):</span> <span class=\"s2\">'+DIAMETER+'</span></li>'
			+'<li> <span class=\"s1\">壁厚(mm):</span> <span class=\"s2\">'+WALL_THICKNESS+'</span></li>'
			+'<li> <span class=\"s1\">管节长度(mm):</span> <span class=\"s2\">'+PIPE_LENGTH+'</span></li>'
			+'<li> <span class=\"s1\">防腐材料:</span> <span class=\"s2\">'+COATING_MATERIAL+'</span></li>'
			+'<li> <span class=\"s1\">防腐层安装地点:</span> <span class=\"s2\">'+COATING_SOURCE+'</span></li>'
			+'<li> <span class=\"s1\">内外防腐:</span> <span class=\"s2\">'+INTER_NALOREXTERNAL+'</span></li>'
			+'<li> <span class=\"s1\">防腐层厚度(mm):</span> <span class=\"s2\">'+COATING_THICKNESS+'</span></li>'
			+'<li> <span class=\"s1\">检漏电压(kV):</span> <span class=\"s2\">'+TEST_VOLTAGE+'</span></li>'
			+'<li> <span class=\"s1\">钢管生产厂家:</span> <span class=\"s2\">'+PIPE_MANUFACTURER+'</span></li>'
			+'<li> <span class=\"s1\">钢管生产日期:</span> <span class=\"s2\">'+PIPE_MANUFACTURE_DATE+'</span></li>'
			+'<li> <span class=\"s1\">防腐层制造厂家:</span> <span class=\"s2\">'+COATING_MANUFACTURER+'</span></li>'
			+'<li> <span class=\"s1\">防腐层制造日期:</span> <span class=\"s2\">'+COATING_MANUFACTURE_DATE+'</span></li>'
			+'<li> <span class=\"s1\">记录人:</span> <span class=\"s2\">'+RECORDER+'</span></li>'
			+'<li> <span class=\"s1\">记录时间:</span> <span class=\"s2\">'+RECORDTIME+'</span></li>'
			+'<li class=\"last-li\"><span class=\"s1\">备注:</span><span class=\"s2\"><textarea readonly="readonly" placeholder=\"备注描述\">'+CREATE_REMARK+'</textarea></span></li>'
			+'</ul></div></div>'

			html += '<div class=\"info-tr\"><ul class=\"ul-header '+ hangClass + '\">' +
                '<li class=\"w20\">' + LINENAME + '</li>' +
                '<li class=\"w20\">' + SEGMENTNAME + '</li>' +
                '<li class=\"w20\">' + PIPE_NUMBER + '</li>' +
                '<li class=\"w10\">' + MANUFACTURED_NUM + '</li>' +
                '<li class="w20">' + MATERIAL + '</li>' +
                '<li class=\"w10 no-right\"><em class=\"xq-icon\"></em></li></ul>'+hhtml

				return html;
}



function getSteelClick(){
    var pagePath = $("#pagePath").val();

    var lineId = $("#lineDiv").children().attr("id");
    var segmentId = $("#segmentDiv").children().attr("id");
    var startMileage = $("#startMileage").val();
    var endMileage = $("#endMileage").val();
    if(lineId == "lineAll" || lineId == "" || lineId == undefined){
        lineId = "";
    }
    if(segmentId == "segmentAll" || segmentId == "" || segmentId == undefined){
        segmentId = "";
    }
    if (startMileage == null || startMileage == "") {
        startMileage = 0;
    }
    if (endMileage == null || endMileage == "") {
        endMileage = 0;
    }

    //给隐藏表单域赋值
    $("input[name='pipeLineId']").val(lineId);
    $("input[name='pipeSegmentId']").val(segmentId);
    $("input[name='startMileage']").val(startMileage);
    $("input[name='endMileage']").val(endMileage);

    var data = {"pipeLineId" : lineId, "pipeSegmentId" : segmentId, "startMileage" : startMileage, "endMileage" : endMileage};

    var b = window.sessionStorage;
    b.removeItem("mapData");
    b.setItem("mapData", JSON.stringify(data));
    var map = {"fillDiv" : "#searchBody", "url" : ""+pagePath+"/basedata/PipeSteelController/getDetails.json"};
    searchPage(map, data);
}

function steelDonwload(){

    var pagePath = $("#pagePath").val();

    var lineId = $("#lineDiv").children().attr("id");
    var segmentId = $("#segmentDiv").children().attr("id");
    var startMileage = $("#startMileage").val();
    var endMileage = $("#endMileage").val();
    if(lineId == "lineAll" || lineId == "" || lineId == undefined){
        lineId = "";
    }
    if(segmentId == "segmentAll" || segmentId == "" || segmentId == undefined){
        segmentId = "";
    }
    if (startMileage == null || startMileage == "") {
        startMileage = 0;
    }
    if (endMileage == null || endMileage == "") {
        endMileage = 0;
    }

    $("input[name='pipeLineId']").val(lineId);
    $("input[name='pipeSegmentId']").val(segmentId);
    $("input[name='startMileage']").val(startMileage);
    $("input[name='endMileage']").val(endMileage);

    $("#steelForm").attr("action", pagePath + "/basedata/PipeSteelController/getExcel.html");
    $("#steelForm").submit();
}
